package itcast.web.servlet;

import itcast.domain.Build;
import itcast.domain.Repair;
import itcast.service.BuildService;
import itcast.service.BuildmanagerService;
import itcast.service.RepairService;
import itcast.service.impl.BuildServiceImpl;
import itcast.service.impl.BuildmanagerServiceimpl;
import itcast.service.impl.RepairServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet("/addRepairServlet")
public class AddRepairServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.设置编码
        request.setCharacterEncoding("utf-8");
        //1.获取id
        String repair_date = request.getParameter("repair_date");

        String student_username =request.getParameter("student_username");
        String student_name=request.getParameter("student_name");
        String build_name=request.getParameter("build_name");
        String drom_name=request.getParameter("drom_name");
        String repair_remark=request.getParameter("repair_remark");

        //2.调用Service增加
        RepairService service=new RepairServiceImpl();
        service.addrepair_information(repair_date,student_username,student_name,build_name,drom_name,repair_remark);
        //5.跳转到repairlist_Servlet
        response.sendRedirect(request.getContextPath()+"/repairxueshengServlet?username="+student_username);
   }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request,response);
    }
}
